package com.zhao.model;

import com.zhao.service.PromotionStrategy;
import lombok.Setter;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

// 购物车
public class ShoppingCart {

    @Setter
    private PromotionStrategy promotionStrategy;

    private Map<Fruit, Integer> fruitQuantities;

    public ShoppingCart(PromotionStrategy promotionStrategy) {
        this.promotionStrategy = promotionStrategy;
        fruitQuantities = new HashMap<>();
    }


    public void addFruit(Fruit fruit, int quantity) {
        fruitQuantities.put(fruit, quantity);
    }

    public BigDecimal calculateTotalPrice() {
        return promotionStrategy.calculate(fruitQuantities);
    }
}